package com.example.eos.controller;

import com.example.eos.bean.ReturnInfo;
import com.example.eos.service.UserFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class UserFollowController {

    private UserFollowService userFollowService;

    @Autowired
    public UserFollowController(UserFollowService userFollowService){
        this.userFollowService = userFollowService;
    }

    //查询用户的关注
    @RequestMapping(value = "/userfollow/follow/{userid}",method = RequestMethod.GET)
    public ReturnInfo findUserFollow(@PathVariable String userid){
        return userFollowService.findUserFollowsOrFans(userid, "关注");
    }

    //查询用户的粉丝
    @RequestMapping(value = "/userfollow/fans/{userid}",method = RequestMethod.GET)
    public ReturnInfo findUserFans(@PathVariable String userid){
        return userFollowService.findUserFollowsOrFans(userid, "粉丝");
    }

    //用户添加关注
    @RequestMapping(value = "/userfollow/{followid}",method = RequestMethod.POST)
    public ReturnInfo addUserFollow(@PathVariable String followid){
        return userFollowService.addUserFollow(followid);
    }

    //删除用户关注
    @RequestMapping(value = "/userfollow/{followid}",method = RequestMethod.DELETE)
    public ReturnInfo deleteUserFollow(@PathVariable String followid){
        return userFollowService.deleteUserFollow(followid);
    }

}
